import { Provide} from '@midwayjs/core';
import { User} from '../../entity/user/user';
import { InjectEntityModel } from '@midwayjs/orm';
import { Repository } from 'typeorm';


@Provide()
export class UserService {

  @InjectEntityModel(User)
  userModel:Repository<User>
  
  async getAllUsers():Promise<User[]>{
    try{
      const result = await this.userModel.find()
      return result
    }catch(err){
      console.log("err",err);
      
    }
  }


  async deleteUser(id){
    try{
      const result = await this.userModel.delete(id)   
      return result
    }catch(err){
      console.log("err",err);
      
    }
  }

}
